package com.study.springboot.SpringBoot_A.mapper;

import com.study.springboot.SpringBoot_A.bean.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 赵超
 * @Description
 * @create 2018-03-28 10:47
 **/
public interface UserMapper {

    @Select("select * from user")
    @Results({
            @Result(property = "userName", column = "user_name"),
            @Result(property = "nickName", column = "nick_name"),
            @Result(property = "passWord", column = "pass_word"),
            @Result(property = "regTime", column = "reg_time")
    })
    List<User> getAll();

    @Insert("insert into user (user_name, nick_name, pass_word) values (#{userName}, #{nickName}, #{passWord})")
    Integer addUser(@Param("userName") String userName, @Param("nickName") String nickName, @Param("passWord") String passWord);
//    Integer addUser(User user);

    @Update("UPDATE user SET userName = #{userName}, nick_name = #{nickName} WHERE id = #{id}")
    Integer updateUser(User user);

    @Delete("DELETE FROM user WHERE id =#{id}")
    void delete(Long id);
}
